package com.atguigu.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

@WebServlet("/servlet4")
public class Servlet4  extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(req.getParameter("username")); //根据参数名获取单个参数
        System.out.println(req.getParameter("password"));
        //根据参数名获取多个产数
        String[] hobbies = req.getParameterValues("hobby");
        System.out.println(Arrays.toString(hobbies));

        Map<String, String[]> parameterMap = req.getParameterMap();
        parameterMap.forEach((key, value) -> System.out.println(key + "-->" + Arrays.toString(value)));

    }
}
